<?php
class TianqiController extends ApiController
{
	public function actionMsg()
	{
		$address  = @$_GET['address'] ? urldecode($_GET['address']) : '北京';
		$citycode = new CityCode();
		$citycode = $citycode->getcitycode($address);
		$url = 'http://m.weather.com.cn/data/'.$citycode.'.html';
		$contents = file_get_contents($url);
		$contents = json_decode($contents);
		if($contents)
		{
			$array = array(
				'code'=>1,
				'data'=>array(
					'Text'=>$contents->weatherinfo->weather1,
					'address'=>$contents->weatherinfo->city,
					'currentWd'=>$contents->weatherinfo->temp1,
				),
			);
		}
		else
		{
			$array = array(
				'code'=>0,
                'msg'=>'对不起，没有相关数据！',
			);
		}
		echo json_encode($array);die;

	}
}